/**
 * ServerThread
 * 
 */
package br.ufal.ic.sd.project.server.thread;

import br.ufal.ic.sd.project.server.core.Server_Channel;

/**
 * @author keven lenisk almeida andrade
 *
 */
public class ServerThread extends Thread{
    

	public Server_Channel objServer_Channel;
	
	/**
	 * Construtor
	 * @param objServer_Channel
	 */
	public ServerThread(Server_Channel objServer_Channel) {
		
		this.objServer_Channel = objServer_Channel;
	}
	
	//=========================================== Getters and Setters ========================================
	
	/**
	 * @return the objServer_Channel
	 */
	public Server_Channel getObjServer_Channel() {
		return objServer_Channel;
	}

	/**
	 * @param objServer_Channel the objServer_Channel to set
	 */
	public void setObjServer_Channel(Server_Channel objServer_Channel) {
		this.objServer_Channel = objServer_Channel;
	}
	
	
	/*
	 * (non-Javadoc)
	 * @see java.lang.Runnable#run()
	 */
	public void run() {
		
		String[] strNumbers = this.objServer_Channel.read().split(",");
		
		int intFirstNumber = Integer.parseInt(strNumbers[0]);
		int intSecondNumber = Integer.parseInt(strNumbers[1]);
		
		System.out.println("Numbers: " + intFirstNumber + " , " + intSecondNumber);
		
		this.objServer_Channel.write("Result: " + intFirstNumber + " + " + intSecondNumber + " = " + (intFirstNumber + intSecondNumber));
	}
	
//	/**
//	 * stop the thread
//	 */
//	public void stop(){
//	    
//	    System.out.println("Connection closed!");
//	    Thread.interrupted();
//	}

	

}
